<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#import "/layout/select.ftl" as my/>
<#assign css>
    <style>
    </style>
</#assign>
<#assign js>
    <script>
        function agree(id) {
            layer.prompt({title: '输入抽成比例', formType: 3}, function (scale, index) {
                if (!$.isNumeric(scale)) {
                    layer.alert('只能填写数字');
                    return;
                }
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    data: {
                        'scale': scale
                    },
                    url: "/partner/agree/" + id,
                    success: function (res) {
                        layer.msg(res.message, {time: 2000}, function () {
                            if (res.code === '0') {
                                location.reload();
                            }
                        });
                    }
                });
            });
        }

        function refuse(id) {
            layer.prompt({title: '输入拒绝原因', formType: 2}, function (reason, index) {
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    data: {
                        'reason': reason
                    },
                    url: "/partner/reject/" + id,
                    success: function (res) {
                        layer.msg(res.message, {time: 2000}, function () {
                            location.reload();
                        });
                    }
                });
            });
        }
    </script>
</#assign>
<@layout title="合作商家管理" active="partner">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            合作商家列表
        </h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-home"></i> 管理后台</a></li>
            <li><a href="/partner/index"><i class="fa fa-list-ul"></i> 合作商家管理</a></li>
            <li class="active"><i class="fa fa-table"></i> 合作商家列表</li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <!-- Default box -->
        <div class="box box-primary">
            <div class="box-header">
                <form class="form-horizontal form-edit" method="post" action="/partner/index" id="searchForm">
                    <div class="form-group" style="margin-top:10px;">
                        <div class="col-sm-2">
                            <input placeholder="请输入商家名称" id="partnerName" name="partnerName" class="form-control"
                                   type="text"
                                   value="${searchUser.partnerName!}">
                        </div>
                        <div class="btn-group">
                            <button type="submit" class="btn btn-primary" data-btn-type="search">查询</button>
                            <button type="button" class="btn btn-default" data-btn-type="reset"
                                    onclick="javascript:$('#searchForm')[0].reset()">重置
                            </button>
                        </div>
                    </div>
                </form>
                <#--<@shiro.hasPermission name="system:user:add">
                    <a class="btn btn-sm btn-success" href="/user/add">新增</a>
                </@shiro.hasPermission>-->
            </div>
            <div class="box-body">
                <table class="table table-striped">
                    <tr>
                        <th>分站ID</th>
                        <th>商家名称</th>
                        <th>电话</th>
                        <th>地址纬度</th>
                        <th>地址经度</th>
                        <th>单笔费用</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    <#list pageInfo.list as item>
                        <tr>
                            <td>${item.agentId!}</td>
                            <td>${item.partnerName!}</td>
                            <td>${item.partnerPhone!}</td>
                            <td>${item.partnerLatitude!}</td>
                            <td>${item.partnerLongitude!}</td>
                            <td>${item.partnerAmount!}</td>
                            <td>
                                <#if item.partnerStatus == 0>
                                    未申请
                                <#elseif item.partnerStatus == 1>
                                    申请中
                                <#elseif item.partnerStatus == 2>
                                    已同意
                                <#else >
                                    已拒绝
                                </#if>
                            </td>
                            <td>
                                <#--<@shiro.hasPermission name="system:user:detail">-->
                                <a class="btn btn-sm btn-success" href="/order/partnerOrderList/${item.id}"
                                   data-btn-type="detail">数据</a>
                                <a class="btn btn-sm btn-success" href="/partner/detail/${item.id}"
                                data-btn-type="detail">详情</a>
                                <#--<@shiro.hasPermission name="system:partner:edit">
                                    <a class="btn btn-sm btn-primary" href="/partner/edit/${item.id}" data-btn-type="edit">编辑</a>
                                </@shiro.hasPermission>
                                &lt;#&ndash;</@shiro.hasPermission>&ndash;&gt;
                                <#if item.partnerStatus?? && item.partnerStatus == 1>
                                    <button class="btn btn-sm btn-success" onclick="agree('${item.id}')">同意</button>
                                    <button class="btn btn-sm btn-danger" onclick="refuse(${item.id})"
                                            data-btn-type="detail">拒绝
                                    </button>
                                </#if>-->
                            </td>
                        </tr>
                    </#list>
                </table>
            </div>
            <!-- /.box-body -->
            <div class="box-footer clearfix">
                <@macro.page pageInfo=pageInfo url="/partner/index?" />
            </div>
        </div>
        <!-- /.box -->

    </section>
    <!-- /.content -->
</@layout>
